<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8" />
		<title>组织表单</title>
		<div th:replace="common/common_form_header"></div>
	</head>
	<style>
		::-webkit-scrollbar{
		    width:4px;
		}
		  ::-webkit-scrollbar-thumb {
			background: rgba(0,0,0,0.1);
		}
		.addemployee-wrap{
			width:100%;
			height:100%;
			padding: 0px 0px 10px 0px;
			box-sizing: border-box;
		}
		.form-wrap{
			width: 100%;
		    padding: 30px 30px 10px 0px;;
		    height: 100%;
		    overflow-y: scroll;
		    box-sizing: border-box;
		}
	</style>
	<body>
		<div class="addemployee-wrap" id="employee-wrap">
			<div class="form-wrap" >
    			<form  class="layui-form" id="defaultForm" th:method="post" th:action="@{/app/contractReceivable/save}">
					<input type="hidden" id="contractInfoId" name="contractInfoId" th:value="${id}"/>
					<input type="text" name="fkDicReceivableType" id="fkDicReceivableType" hidden="hidden" th:value="0">
					<div class="layui-form-item">
						<div class="layui-inline">
						    <label class="layui-form-label">阶段开始</label>
						    <div class="layui-input-inline" style="width:180px">
						      	<input type="text" name="startDate" id="startDate" lay-verify="startDate"  autocomplete="off" class="layui-input">
						    </div>
						</div>
						<div class="layui-inline">
						    <label class="layui-form-label" style="width:60px">阶段终止</label>
						    <div class="layui-input-inline" style="width:180px">
						    	<input type="text" name="endDate" id="endDate" lay-verify="endDate"  autocomplete="off" class="layui-input">
						    </div>
						</div>
					</div>
					<div class="layui-form-item">
					    <label class="layui-form-label">月租金</label>
					    <div class="layui-input-block">
						    <input type="text" name="rent" id="rent" required  lay-verify="rent" class="layui-input">
							<span style="color: rgb(153, 153, 153); font-size: 12px; padding: 4px 0px 0px;">输入整月的总体金额</span>
						</div>
					</div>
					<div class="layui-form-item">
					    <label class="layui-form-label">租金周期</label>
					    <div class="layui-input-block">
						    <select lay-filter="aihao" name="interest">
						        <option value="1" selected="" >一个月</option>
						        <option value="2">二个月</option>
						        <option value="3">三个月</option>
						        <option value="4">四个月</option>
						        <option value="5">五个月</option>
						        <option value="6">六个月</option>
						        <option value="7">七个月</option>
						        <option value="8">八个月</option>
						        <option value="9">九个月</option>
						        <option value="10">十个月</option>
						        <option value="11">十一个月</option>
						        <option value="12">十二个月</option>
						    </select>
						</div>
					</div>
					<div class="layui-form-item">
					    <label class="layui-form-label">缴租日</label>
					    <div class="layui-input-block">
					    	<br>
							<span style="color: rgb(153, 153, 153); font-size: 12px; padding: 4px 0px 0px;">租金周期开始日前7天</span>
						</div>
					</div>
					<div class="layui-form-item">
				    <label class="layui-form-label">备注</label>
				    <div class="layui-input-block">
				      	<textarea placeholder="" id="introduction" required  lay-verify="introduction"  name="introduction" class="layui-textarea"></textarea>
				    </div>
				</div>
					<div class="layui-form-item" style="position: fixed;">
					    <div class="layui-input-block">
					      <button class="layui-btn layui-btn-normal btn-bg" lay-submit lay-filter="formEmployee" id="submit-btn">确定</button>
					      <a class="layui-btn layui-btn-primary" onclick="closeLayer()">取消</a>
					    </div>
					</div>
					
				</form>
    		</div>
    	</div>
	</body>
	<script>
	
	window.onload = function(){
		//console.log($(window.parent.document).contents().find("#team-iframe"),"oooooo")
		
	}
	$(document).ready(function() {
		var iframe0=$(window.parent.document).find('.iframe-wrap').children("iframe"),
		teamIframe=$(iframe0),
		startTime=$(teamIframe).contents().find('#startDate').val(),
		endTime=$(teamIframe).contents().find('#endDate').val(),
		deposit=$(teamIframe).contents().find('#deposit').val()||0,
		month = $(teamIframe).contents().find("select[name='interest']").val()||1;
		if(endTime==undefined||endTime==''){
			endTime=startTime;
		}
		$('#rent').val(deposit/month);
		$("#startDate").val(startTime);
		$("#endDate").val(endTime)
	});
	layui.config({
	        base: '/js/plugin/layui-v2.3.0/layui/' //此处路径请自行处理, 可以使用绝对路径
	    }).extend({
	        formSelects: 'formSelects-v3'
	    }).use(['element',"layer","form",'formSelects', 'laydate'], function(){
			var layer=layui.layer,form = layui.form,formSelects = layui.formSelects,laydate = layui.laydate;
			//日期
			laydate.render({
			  elem: '#startDate'
			});
			laydate.render({
			  elem: '#endDate'
			});
			form.verify({
				endDate: function(value, item){ //value：表单的值、item：表单的DOM对象
					var startDate = $("#startDate").val();
					if(value <= startDate){
			       		  return '结束日期不能早于开始日期';
			      	}
			  	}
			/* ,foldername: function(value, item){ //value：表单的值、item：表单的DOM对象
		      	  	if(value==""){
			       		  return '组织名称不能为空';
			      	}
			  	} */
			}); 
			//监听提交
			form.on('submit(formEmployee)', function(data){
				$.post($("#defaultForm").attr('action'), data.field, function(result) {
					window.parent.layer.msg(result.msg);
					closeLayer();
				}, 'json');
				return false;
			});
		});
	
</script>
</html>